<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/8/16
 * Time: 11:18
 */
namespace  app\models;

use Phalcon\Mvc\Model;

class Robots extends Model
{
    public function getSource()
    {
        return 'robots';
    }

    protected $id;
    protected $name;
    protected $price;

    public function getId()
    {
        return $this->id;
    }

    public function initialize()
    {
        $this->hasMany('id', 'RobotsParts', 'robots_id');
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        if (strlen($name) < 4) {
            throw new \InvalidArgumentException('invalid argument');
        }
        $this->name = $name;
    }

    public function getPrice()
    {
        return doubleval($this->price);
    }

    public function setPrice($price)
    {
        if ($price < 0) {
            throw new \InvalidArgumentException('price can\'t be negative');
        }
        $this->price = $price;
    }
}